package service

import (
	"log"
	"net/http"
	"time"

    appService "geek-go/week03/appService"
)

func main() {
	s1 := &http.Server{
		Addr:    "127.0.0.1:8080",
		Handler: nil,
	}
	s2 := &http.Server{
		Addr:    "127.0.0.1:8081",
		Handler: nil,
	}

	logger := log.Default()

	app := appService.NewApp(
		appService.WithServer(s1),
		appService.WithServer(s2),
		appService.WithLog(logger),
	)

	// 测试3s后退出。
	time.AfterFunc(time.Second*3, func() {
		app.Stop()
	})

	if err := app.Run(); err != nil {
		log.Printf("%v", err)
	}

	logger.Println("app service has exited")
}
